package yn.micro.common.factory;

import yn.micro.common.annotion.ExcepEnumType;

/**
 * 异常枚举code值快速创建
 *
 * @author yjs
 * @date 2020-12-11 18:09
 */
public class ExcepEnumCodeFactory {

    public static Integer getExcepEnumCode(Class<?> clazz, int code) {

        // 默认的异常响应码
        Integer defaultCode = Integer.valueOf("" + 99 + 9999 + 9);

        if (clazz == null) {
            return defaultCode;
        } else {
            ExcepEnumType expEnumType = clazz.getAnnotation(ExcepEnumType.class);
            if (expEnumType == null) {
                return defaultCode;
            }
            return Integer.valueOf("" + expEnumType.module() + expEnumType.kind() + code);
        }

    }

}